package  
{
	import flash.text.TextField;
	import flash.desktop.NativeApplication;
	/**
	 * ...
	 * @author patsup
	 * 
	 * 		This uses the old "StartMenuBtn" instead of the more generalized "MenuButton"
	 * 	(which uses the ImageData class to draw itself).
	 * 
	 * *** protected functions
	 * 
	 * InitImage():void
	 * NewBtnInputMouseClick():void
	 * LoadBtnInputMouseClick():void
	 * InfoBtnInputMouseClick():void
	 * HSBtnInputMouseClick():void
	 * ExitBtnInputMouseClick():void
	 */
	public class StartMenu extends Menu 
	{
		//start menu image parameters
		private const SM_COLOR:int = 0xFFFF80;
		private const SM_WIDTH:int = 640;
		private const SM_HEIGHT:int = 480;
		
		private const NEW_BUTTON_X_STARTLOC:int = 250;			//Button for New Game
		private const NEW_BUTTON_Y_STARTLOC:int = 130;
		private const LOAD_BUTTON_X_STARTLOC:int = 250;			//Button for Load Game
		private const LOAD_BUTTON_Y_STARTLOC:int = 180;
		private const INFO_BUTTON_X_STARTLOC:int = 250;			//Button for Info
		private const INFO_BUTTON_Y_STARTLOC:int = 230;
		private const HIGH_SCORE_BUTTON_X_STARTLOC:int = 250;	//Button for High Score
		private const HIGH_SCORE_BUTTON_Y_STARTLOC:int = 280;
		private const EXIT_BUTTON_X_STARTLOC:int = 250;			//Button for Exit Game
		private const EXIT_BUTTON_Y_STARTLOC:int = 330;
		
		private var txtLabel:TextField;				//label
		
		private var mainRef:Main;
		
		private var newButton:StartMenuBtn;
		private var loadButton:StartMenuBtn;
		private var infoButton:StartMenuBtn;
		private var highScoreButton:StartMenuBtn;
		private var exitButton:StartMenuBtn;
		
		public function StartMenu(mainRef:Main) 
		{
			txtLabel = new TextField();
			this.mainRef = mainRef;
			InitImage();
		}
		
		//InitImage()
		//Initializes the image of the StartMenu
		protected override function InitImage():void
		{
			graphics.beginFill(SM_COLOR);
			graphics.drawRect(0, 0, SM_WIDTH, SM_HEIGHT);
			graphics.endFill();
			
			txtLabel.text = "Start Menu";
			addChild(txtLabel);
			
			//newButton = new StartMenuBtn(NEW_BUTTON_X_STARTLOC, NEW_BUTTON_Y_STARTLOC, "New Game", NewBtnInputMouseClick);
			loadButton = new StartMenuBtn(LOAD_BUTTON_X_STARTLOC, LOAD_BUTTON_Y_STARTLOC, "Start", LoadBtnInputMouseClick);
			infoButton = new StartMenuBtn(INFO_BUTTON_X_STARTLOC, INFO_BUTTON_Y_STARTLOC, "Info", InfoBtnInputMouseClick);
			highScoreButton = new StartMenuBtn(HIGH_SCORE_BUTTON_X_STARTLOC, HIGH_SCORE_BUTTON_Y_STARTLOC,
																						"High Scores", HSBtnInputMouseClick);
			exitButton = new StartMenuBtn(EXIT_BUTTON_X_STARTLOC, EXIT_BUTTON_Y_STARTLOC,
																						"Exit Game", ExitBtnInputMouseClick);
			//addChild(newButton);
			addChild(loadButton);
			addChild(infoButton);
			addChild(highScoreButton);
			addChild(exitButton);
			
			super.InitImage();
		}
		
		//NewBtnInputMouseClick()
		//called on new button mouse click
		protected function NewBtnInputMouseClick():void
		{
			mainRef.ResetGame();
			mainRef.DisplayNewRound(this);
		}
		//LoadBtnInputMouseClick()
		//called on load button mouse click
		protected function LoadBtnInputMouseClick():void
		{
			mainRef.DisplayLoadMenu(this);
		}
		//InfoBtnInputMouseClick()
		//called on info button mouse click
		protected function InfoBtnInputMouseClick():void
		{
			mainRef.DisplayInfoMenu(this);
		}
		//HSBtnInputMouseClick()
		//called on high score button mouse click
		protected function HSBtnInputMouseClick():void
		{
			mainRef.DisplayHighScores(this);
		}
		//ExitBtnInputMouseClick()
		//called on exit game button mouse click
		protected function ExitBtnInputMouseClick():void
		{
			NativeApplication.nativeApplication.exit();
		}
	}

}